/**
 * @Project : ProgrammingExercises
 * @Package : Leetcode
 * @File : Q0746.java
 * @Author : WangRuoyu
 * @Date 2023/1/12 15:40
 */

package leetcode;

public class Q0746 {
    public int minCostClimbingStairs(int[] cost) {
        int[] f = new int[cost.length + 1];
        f[0] = 0;
        f[1] = 0;
        for (int i = 2; i <= cost.length; i++) {
            f[i] = Math.min(f[i - 2] + cost[i - 2], f[i - 1] + cost[i - 1]);
        }
        return f[cost.length];
    }

    public static void main(String[] args) {
        Q0746 sl = new Q0746();
        int[] cost = {10, 15, 20};
        System.out.println(sl.minCostClimbingStairs(cost));
    }
}
